package com.actions.bluetoothbox2.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.actions.bluetoothbox2.R;

/**
 * Created by liuyong on 2017/12/26.
 */

public class PopMusicSelectAdapter extends BaseAdapter {


    Context context;
    int[] imgID;

    public PopMusicSelectAdapter(Context context, int[] imgID) {
        this.context = context;
        this.imgID = imgID;
    }

    @Override
    public int getCount() {
        return imgID.length;
    }

    @Override
    public Object getItem(int position) {
        return imgID[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_color_select, parent, false);
        }
        ImageView img_ico = (ImageView) convertView.findViewById(R.id.img_ico);
        img_ico.setImageResource(imgID[position]);
        return convertView;
    }
}
